package com.jiegui.business.controller;

import java.util.Arrays;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jiegui.common.annotation.Log;
import com.jiegui.common.core.controller.BaseController;
import com.jiegui.common.core.domain.AjaxResult;
import com.jiegui.common.enums.BusinessType;
import com.jiegui.business.domain.IndeHomeInfo;
import com.jiegui.business.service.IndeHomeInfoService;
import com.jiegui.common.utils.poi.ExcelUtil;
import com.jiegui.common.core.page.TableDataInfo;

/**
 * 首页轮播图管理Controller
 * 
 * @author wuqicheng
 * @date 2024-11-20
 */
@RestController
@RequestMapping("/business/indeHomeInfo")
public class IndeHomeInfoController extends BaseController
{
    @Resource
    private IndeHomeInfoService indeHomeInfoService;

    /**
     * 查询首页轮播图管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:indeHomeInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(IndeHomeInfo indeHomeInfo)
    {
        startPage();
        List<IndeHomeInfo> list = indeHomeInfoService.selectIndeHomeInfoList(indeHomeInfo);
        return getDataTable(list);
    }

    /**
     * 导出首页轮播图管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:indeHomeInfo:export')")
    @Log(title = "首页轮播图管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(IndeHomeInfo indeHomeInfo)
    {
        List<IndeHomeInfo> list = indeHomeInfoService.selectIndeHomeInfoList(indeHomeInfo);
        ExcelUtil<IndeHomeInfo> util = new ExcelUtil<IndeHomeInfo>(IndeHomeInfo.class);
        return util.exportExcel(list, "首页轮播图管理数据");
    }

    /**
     * 获取首页轮播图管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:indeHomeInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(indeHomeInfoService.selectIndeHomeInfoById(id));
    }

    /**
     * 新增首页轮播图管理
     */
    @PreAuthorize("@ss.hasPermi('business:indeHomeInfo:add')")
    @Log(title = "首页轮播图管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IndeHomeInfo indeHomeInfo)
    {
        return toAjax(indeHomeInfoService.insertIndeHomeInfo(indeHomeInfo));
    }

    /**
     * 修改首页轮播图管理
     */
    @PreAuthorize("@ss.hasPermi('business:indeHomeInfo:edit')")
    @Log(title = "首页轮播图管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IndeHomeInfo indeHomeInfo)
    {
        return toAjax(indeHomeInfoService.updateIndeHomeInfo(indeHomeInfo));
    }

    /**
     * 删除首页轮播图管理
     */
    @PreAuthorize("@ss.hasPermi('business:indeHomeInfo:remove')")
    @Log(title = "首页轮播图管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(indeHomeInfoService.removeByIds(Arrays.asList(ids)));
    }


}
